{% extends "base.html" %}

{% block title %} Book List{% endblock %}

{% load humanize %}
{% block content %}

<p>Found {{ book_sale_logs|length }} book{{ book_sale_logs|length|pluralize }} sold between {{ from_date }} and {{ to_date }}</p>
{% ifnotequal book_sale_logs|length 0 %}
<table>
  <thead>
    <tr>
      <th>Ref</th>
      <th>Title</th>
      <th>Seller</th>
      <th>Buyer</th>
      <th>Date Sold</th>
    </tr>
  </thead>
  <tbody>
    {% for log in book_sale_logs %}
    <tr>
      <td><a href="{% url book log.book.id %}">{{ log.book.id }}</a></td>
      <td>{{ log.book.metabook.title }}</td>
      <td>
          {% if log.book.seller %}
          <a href="{% url user log.book.seller.id %}">{{ log.book.seller.get_full_name}}</a>
          {% endif %}
      </td>
      <td>
        {% if log.book.holder %}
        <a href="{% url user log.book.holder.id %}">{{ log.book.holder.get_full_name}}</a>
        {% endif %}
      </td>
      <td title="{{ log.book.sell_date }}">{{ log.book.sell_date|naturalday }}</td>
    </tr>
    {% endfor %}
   </tbody>
</table>
{% endifnotequal %}
{% endblock %}
